﻿namespace NH3.Mapping
{
	using FluentNHibernate.Mapping;
	using NH3.Model;

	public sealed class CustomerMapping : ClassMap<Customer>
	{
		public CustomerMapping()
		{
			OptimisticLock.Dirty();
			
			DynamicUpdate();
			
			Table("Cliente");

			Id(c => c.Id);

			Map(c => c.Company)
				.Column("Compagnia");

			Component(c => c.CompanyAddress);

			HasMany(c => c.Projects)
				.KeyColumn("ClienteId")
				.Inverse()
				.Cascade.All();
		}
	}
}
